package com.sanctity;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.sanctity.clients.InPatientClient;
import com.sanctity.clients.UserClient;
import com.sanctity.config.FeignDefaultConfig;
import com.sanctity.feign.clients.PatientClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import tk.mybatis.spring.annotation.MapperScan;

@MapperScan("com.sanctity.mapper")
@SpringBootApplication
@EnableFeignClients(clients = {PatientClient.class, InPatientClient.class, UserClient.class})
public class OrderApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    /**
     * 使用配置类注册全局Ribbon负载均衡策略
     * @return

    @Bean
    public IRule loadBalanced(){
        return new RandomRule();
    }
     */
}
